$(function() {

    $('.header .banner-slider').slick({
        autoplay: true,
        dots: true,
        arrows: true,
        pauseOnHover: false,
        appendDots: $('.header .dots'),
        appendArrows: $('.header .arrows'),
        nextArrow: $('.header .arrows .next'),
        prevArrow: $('.header .arrows .prev')
    })

    $('.focus .slider').slick({
            autoplay: true,
            dots: true,
            arrows: true,
            pauseOnHover: true,
            appendDots: $('.focus .dots'),
            appendArrows: $('.focus .arrows'),
            nextArrow: $('.focus .arrows .next'),
            prevArrow: $('.focus .arrows .prev')
        })
        //briefs
    $('.briefs').slick({
        autoplay: false,
        dots: false,
        arrows: false,
        pauseOnHover: true
    })
    $(".briefs").on('afterChange', function(event, slick, currentSlide) {
        $('.bulltetin .head .item').removeClass('active')
        $('.bulltetin .head .item').eq(currentSlide).addClass('active')
    });

    $('.bulltetin .head .item').mouseover(function() {
        $('.bulltetin .head .item').removeClass('act')
        $(this).addClass('act')
        $(".briefs").slick('slickGoTo', $(this).index(), false);
    })
    $(".briefs .brief .item").hover(function() {
        $(".briefs .brief .item").removeClass('hover')
        $(this).addClass('hover')
        console.log($(".briefs .brief .item").length)
    }, function() {
        $(".briefs .brief .item").removeClass('hover')
        for (i = 0; i < 8; i++) {
            //$(".briefs .brief .item").eq(4 * i).addClass('hover')
        }

    })

    //show
    $('.show .sliders').slick({
        autoplay: true,
        dots: false,
        arrows: false,
        pauseOnHover: true
    })
    $('.show .sliders').on('afterChange', function(event, slick, currentSlide) {
        $('.show .head .item').removeClass('active')
        $('.show .head .item').eq(currentSlide).addClass('active')
    });

    $('.show .head .item').mouseover(function() {
        $('.show .head .item').removeClass('act')
        $(this).addClass('act')
        $('.show .sliders').slick('slickGoTo', $(this).index(), false);
    })

    //report
    $('.report .sliders').slick({
        autoplay: false,
        dots: false,
        arrows: false,
        pauseOnHover: true
    })
    $('.report .sliders').on('afterChange', function(event, slick, currentSlide) {
        $('.report .head .item').removeClass('active')
        $('.report .head .item').eq(currentSlide).addClass('active')
    });

    $('.report .head .item').mouseover(function() {
        $('.report .head .item').removeClass('act')
        $(this).addClass('act')
        $('.report .sliders').slick('slickGoTo', $(this).index(), false);
    })



    $('.topics .slider').slick({
        autoplay: true,
        dots: false,
        arrows: true,
        pauseOnHover: true,
        slidesToShow: 4,
        slidesToScroll: 4,
        appendArrows: $('.topics .arrows'),
        nextArrow: $('.topics .arrows .next'),
        prevArrow: $('.topics .arrows .prev')
    })
    $('.functions .slider').slick({
        autoplay: false,
        dots: false,
        arrows: true,
        slidesToShow: 7,
        slidesToScroll: 1,
        appendArrows: $('.functions .arrows'),
        nextArrow: $('.functions .arrows .next'),
        prevArrow: $('.functions .arrows .prev')
    })

    //导航固定
    document.addEventListener('scroll', function() {
        var h = document.documentElement.scrollTop || document.body.scrollTop;
        var shortcut = document.querySelector('.shortcuts')
        var nav = document.querySelector('.header .nav');
        var wrap = document.querySelector('.header .nav .wrap');

        if (h > 0) {
            shortcut.style.position = 'fixed';
            nav.style.position = 'fixed';
            nav.style.top = '48px'
            wrap.style.lineHeight = "90px";
            $('.header .nav .sub').css('top', "90px");
            //$('.header .nav .sub').css('backgroundColor', "#417fbc");
            nav.style.backgroundColor = "#417fbc"

        } else {
            shortcut.style.position = 'static'
            nav.style.position = 'absolute';
            nav.style.top = '0px'
            wrap.style.lineHeight = "111px";
            $('.header .nav .sub').css('top', "111px");
            //$('.header .nav .sub').css('backgroundColor', "#043a81");
            nav.style.backgroundColor = "#00000028"
                // if ($('.sidetools .a5').css('display') == 'block') {
                //     $('.sidetools .a5').hide()
                // }
        }
    })

    //sidetools

    $('.sidetools .shut').on('click', function() {
        $('.sidetools').hide();
    })
    $('.sidetools .a5').on('click', function() {
        window.scrollTo({
            top: 0, // 滚动终点y的位置
            left: 0, // 滚动终点x的位置
            behavior: 'smooth' //平滑滚动
        });
    })

    //searchbar 
    $('.search').on('click', function() {
        $('.searchlayer').fadeIn(300)
        $('.searchlayer .inp').focus()
    })
    $('.searchlayer .close').on('click', function() {
        $('.searchlayer').fadeOut(300)
    })

    //a
    //a
    var ah =document.querySelectorAll('a')
    for (let i=0; i<ah.length; i++) {
        if(ah[i].getAttribute('href').toLowerCase().indexOf('javascript') ==-1){
            ah[i].setAttribute('target','_blank')
        }
    }

})